<div id="rbac_role_index">

    <div class="btn-toolbar m-b">
        <button class="btn btn-default" type="button" @click="add">新增</button>
    </div>

    <datatable
        ref="datatable"
        index="id"
        request="rbac/Role/index"
        :fields="fileds"
        header="<th>角色名</th><th style='width:100px'>操作</th>"
    >
        <div slot="oprate">
            <span @click="edit">修改</span> |
            <span @click="del">删除</span>
        </div>
    </datatable>

</div>

<script>
    new Vue({
        el:'#rbac_role_index',
        data:{
            fileds:[
                'name'
            ]
        },
        methods:{
            _getId:function (e) {
                return $(e.target).parents('tr').data('id') ;
            },
            add:function(){
                go('rbac/Role/save')
            },
            edit:function(e){
                go('rbac/Role/save?id='+this._getId(e))
            },
            del:function(e){
                var id = this._getId(e) ;
                var _this = this ;
                bootbox.confirm("确定要删除？", function(ok){
                    if(!ok){ return }
                    $.get('rbac/Role/delete',{id:id},function(d){
                        if(d.code == 0){
                            success("操作成功")
                            _this.$refs.datatable.refresh()
                        }
                    })
                });
            },
        }
    })
</script>
<script>

</script>